#ifndef ADVANCESETTINGPAGE_H
#define ADVANCESETTINGPAGE_H

#include <QWidget>
#include <QHash>
#include <QThread>
#include "../remoteservice/configinfo.h"
#include "../remoteservice/networkinfo.h"
#include "../remoteservice/newversioninfo.h"
#include "../remoteservice/systemstatusinfo.h"

namespace Ui {
class AdvanceSettingPage;
}

class SmallBlock;
class AdvanceSetWorker;
class VolueControl;

class AdvanceSettingPage : public QWidget
{
    Q_OBJECT
    
public:
    explicit AdvanceSettingPage(QWidget *parent = 0);
    ~AdvanceSettingPage();

signals:
    void updateStatus(int);

protected:
    bool eventFilter(QObject *o, QEvent *e);
    void showEvent(QShowEvent *);
    void hideEvent(QHideEvent *);

private slots:
    void updateNetInfo(QString ip, QString mask, QString gateway, QString dns);
    void updateConfig(QString key, QString value);
    void updateSysInfo(QString status, QString time,
                       QString resource, QString disk);

    void yesnoChanged(int);
    void callrateChanged(int);
    void dealDHCP(QString);

    void on_pushButton_clicked();

    void showKeyBoard();
    void receiveInput();

    void lineEditFinish(QString);

    void on_pbUpdate_clicked();

    void configSlot(ConfigInfo);
    void newVersionSlot(NewVersionInfo);
    void sysStatusSlot(SystemStatusInfo);
    void networkStatusSlot(NetworkInfo);
    void modifyConfigResponseSlot(BaseResp);
    void modifyNetworkResponseSlot(BaseResp);
    void updateResponseSlot(BaseResp);

    void refreshSysStatus();
    void reboot();

private:
    void initNetSettingWidget();
    void initCallSettingWidget();
    void initFocusOrder();

    void setItemIndex(QString name, int index);
    
private:
    Ui::AdvanceSettingPage *ui;
    QHash<QObject*, QList<QObject*> > m_ctrlOrder;

    AdvanceSetWorker *worker;
    QThread workThread;
    QHash<QString, int> m_strIndex;
    QHash<int, QString> m_indexStr;
    QString m_currentRate;
    VolueControl *m_upprocess;
    QTimer *timer;
    QTimer *timerquit;
    int m_inUpdate;

};

#endif // ADVANCESETTINGPAGE_H
